# -*- coding: utf-8 -*-
# @Time    : 2020/3/18 上午10:13
# @Author  : lilong

import logging

logging.basicConfig(level=logging.INFO)


# 装饰器修饰函数
# ==============================
def loggingDecorator(func):
    """记录日志的装饰器"""

    def wrapperLogging(*args, **kwargs):
        print("开始执行 %s() ..." % func.__name__)
        func(*args, **kwargs)
        print("%s() 执行完成！" % func.__name__)

    return wrapperLogging


def showInfo(*args, **kwargs):
    print("这是一个测试函数，参数：", args, kwargs)


decoratedShowInfo = loggingDecorator(showInfo)
decoratedShowInfo('arg1', 'arg2', kwarg1=1, kwarg2=2)
print("#########################")


# ==============================
def showMin(a, b):
    print("%d、%d 中的最小值是：%d" % (a, b, a + b))


decoratedShowMin = loggingDecorator(showMin)
decoratedShowMin(2, 3)
print("#########################")


@loggingDecorator
def showMin(a, b):
    print("%d、%d 中的最小值是：%d" % (a, b, a + b))


showMin(2, 3)
